using Senparc.Weixin.Entities;
using Senparc.Weixin.MP.CommonAPIs;
using System;
namespace Senparc.Weixin.MP.AdvancedAPIs
{
	public static class TenPay
	{
		public static string NativePay(string sign, string appId, string timesTamp, string nonceStr, string productId)
		{
			string format = "weixin://wxpay/bizpayurl?sign={0}&appid={1}&productid={2}&timestamp={3}&noncestr={4}";
			return string.Format(format, new object[]
			{
				sign,
				appId,
				productId,
				timesTamp,
				nonceStr
			});
		}
		public static WxJsonResult Delivernotify(string appId, string openId, string transId, string out_Trade_No, string deliver_TimesTamp, string deliver_Status, string deliver_Msg, string app_Signature, string sign_Method = "sha1")
		{
			string token = AccessTokenContainer.GetToken(appId, false);
			string urlFormat = "https://api.weixin.qq.com/pay/delivernotify?access_token={0}";
			var data = new
			{
				appid = appId,
				openid = openId,
				transid = transId,
				out_trade_no = out_Trade_No,
				deliver_timestamp = deliver_TimesTamp,
				deliver_status = deliver_Status,
				deliver_msg = deliver_Msg,
				app_signature = app_Signature,
				sign_method = sign_Method
			};
			return CommonJsonSend.Send<WxJsonResult>(token, urlFormat, data, CommonJsonSendType.POST, 10000, false);
		}
		public static OrderqueryResult Orderquery(string appId, string package, string timesTamp, string app_Signature, string sign_Method)
		{
			string token = AccessTokenContainer.GetToken(appId, false);
			string urlFormat = "https://api.weixin.qq.com/pay/orderquery?access_token={0}";
			var data = new
			{
				appid = appId,
				package = package,
				timestamp = timesTamp,
				app_signature = app_Signature,
				sign_method = sign_Method
			};
			return CommonJsonSend.Send<OrderqueryResult>(token, urlFormat, data, CommonJsonSendType.POST, 10000, false);
		}
	}
}
